from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
from pydantic_validation_decorator import NotBlank
from typing import Optional
from module_admin.annotation.pydantic_annotation import as_query




class OcrConfigModel(BaseModel):
    """
    OCR配置表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='ID')
    conf_key: Optional[str] = Field(default=None, description='配置key')
    conf_value: Optional[str] = Field(default=None, description='配置值')
    conf_remark: Optional[str] = Field(default=None, description='配置描述')


class AddOcrConfigModel(BaseModel):
    """
    新增OCR配置表对应pydantic模型（不包含自增ID）
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    conf_key: Optional[str] = Field(default=None, description='配置key')
    conf_value: Optional[str] = Field(default=None, description='配置值')
    conf_remark: Optional[str] = Field(default=None, description='配置描述')


class EditOcrConfigModel(BaseModel):
    """
    编辑OCR配置表对应pydantic模型（必须包含ID）
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: int = Field(description='ID（必需）')
    conf_key: Optional[str] = Field(default=None, description='配置key')
    conf_value: Optional[str] = Field(default=None, description='配置值')
    conf_remark: Optional[str] = Field(default=None, description='配置描述')


class OcrConfigQueryModel(OcrConfigModel):
    """
    OCR配置不分页查询模型
    """
    pass


@as_query
class OcrConfigPageQueryModel(OcrConfigQueryModel):
    """
    OCR配置分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteOcrConfigModel(BaseModel):
    """
    删除OCR配置模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    ids: str = Field(description='需要删除的ID')
